package com.coreJava.bingfabao;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.Semaphore;
import java.util.concurrent.locks.Condition;

/**
 * 作者: LCG
 * 日期: 2020/2/10 23:16
 * 描述: 这个类测试一些并发包下边的类
 */
public class TestBingFaBao {
    public static void main(String[] args) throws InterruptedException {

       /* CountDownLatch countDownLatch = new CountDownLatch(2);

        Thread t1=new Thread(new TestCount1(countDownLatch),"A");
        t1.start();
        Thread t2=new Thread(new TestCount2(countDownLatch),"B");
        t2.start();

        countDownLatch.await();//在这个位置阻塞
        System.out.println("=======都运行完毕了======");*/


        /*CyclicBarrier cyclicBarrier=new CyclicBarrier(2);

        Thread t1=new Thread(new TestCount1(cyclicBarrier),"A");
        t1.start();
        Thread t2=new Thread(new TestCount2(cyclicBarrier),"B");
        t2.start();

        System.out.println("=====================");//不阻塞主线程*/

        //只有几个资源，怎么共享的问题
        Semaphore semaphore=new Semaphore(1);

        Thread t1=new Thread(new TestSem1(semaphore),"A");
        t1.start();
        Thread t2=new Thread(new TestSem2(semaphore),"B");
        t2.start();

        System.out.println("==========");//不会阻塞主线程的

        //并发包下的
        //ConcurrentHashMap

    }
}
